Skip to content

Check for a APT Release file in the github workflow: #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cmosetick
Copy link
Member

@igorpecovnik can you please review and submit any feedback here.

Thank you

 -The goal is to do more than check if the Mirror is simply 'online', but actually useable
 - WIP to resolve armbian#56
Copy link
Contributor

coderabbitai bot commented Jul 16, 2025

Walkthrough

The workflow script for generating the redirector configuration was updated to improve how mirror usability is determined. The new logic checks for the presence of at least one "Release" file in the downloaded "compare/dists" directory for each mirror. If no Release file is found, a "no_release" status is recorded for that server, and this status is written to a file and set as an environment variable. Additionally, the workflow's summary output now includes a section listing all servers with the "no_release" status, making missing Release files explicitly visible in the summary.

Assessment against linked issues

Objective Addressed Explanation
Implement comprehensive method to determine if a mirror is usable by checking for a Release file (#56)
Explicitly report and summarize mirrors missing Release files in workflow output (#56)
Update only workflow logic without altering exported/public entities (#56)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found. All modifications are directly related to the objectives stated in the linked issue, focusing on mirror usability checks and reporting within the workflow logic.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (4)
.github/workflows/generate-redirector-config.yml (4)

255-261: Same un-initialised exit_status / find issue as above – please replicate the fix suggested for lines 190-196.


461-463: Same grep failure mode as commented at 427-429 – please apply the same guard.


494-496: Same grep failure mode as commented at 427-429 – please apply the same guard.


528-530: Same grep failure mode as commented at 427-429 – please apply the same guard.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9425386 and 2dbe1ce.

📒 Files selected for processing (1)
  • .github/workflows/generate-redirector-config.yml (6 hunks)

Comment on lines +427 to 429
echo "# No Release file" >> $GITHUB_STEP_SUMMARY
grep no_release status/* | cut -d":" -f1 | xargs awk 'FNR==2{print}' >> $GITHUB_STEP_SUMMARY

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

grep … | awk pipeline will fail when there are no no_release files

If no mirror is missing a Release file grep exits 1 and, with pipefail, the whole step fails. Add a fallback:

-grep no_release status/* | cut -d":" -f1 | xargs awk 'FNR==2{print}' >> $GITHUB_STEP_SUMMARY
+grep -q no_release status/* 2>/dev/null && \
+  grep no_release status/* | cut -d":" -f1 | xargs awk 'FNR==2{print}' >> $GITHUB_STEP_SUMMARY || true

Repeat for the three other summary blocks (lines 461-463, 494-496, 528-530).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "# No Release file" >> $GITHUB_STEP_SUMMARY
grep no_release status/* | cut -d":" -f1 | xargs awk 'FNR==2{print}' >> $GITHUB_STEP_SUMMARY
echo "# No Release file" >> $GITHUB_STEP_SUMMARY
grep -q no_release status/* 2>/dev/null && \
grep no_release status/* | cut -d":" -f1 | xargs awk 'FNR==2{print}' >> $GITHUB_STEP_SUMMARY || true
🤖 Prompt for AI Agents
In .github/workflows/generate-redirector-config.yml around lines 427 to 429, the
pipeline using grep and awk fails when no files match "no_release" because grep
exits with status 1, causing the step to fail under pipefail. To fix this,
modify the command to provide a fallback that prevents failure when no matches
are found, such as appending "|| true" after the grep pipeline. Apply the same
fix to the similar summary blocks at lines 461-463, 494-496, and 528-530.

Comment on lines +190 to +196
# Check for at least one Release file
RELEASE_FOUND=$(find compare/dists -type f -name Release | wc -l)
if [[ "$RELEASE_FOUND" -eq 0 ]]; then
echo "no_release" >> status/${SERVER_ID}
echo "${SERVER_URL}" >> status/${SERVER_ID}
echo "STATUS=no_release" >> $GITHUB_ENV
elif [[ -z "${OUT}" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

exit_status is never initialised & find can break ‑ leads to false classifications

  1. exit_status is referenced later in the same case clause, but it is never set in this job (the lftp call is followed by || true, discarding its exit code). Every server that reaches this branch will therefore evaluate [[ "${exit_status}" -eq 0 ]] as [[ -eq 0 ]] (empty → 0) and be marked not_in_sync even when the mirror is fine.
  2. find compare/dists … errors out (status = 1) when compare/dists does not exist (e.g. 404/timeout). With set -e -o pipefail (GitHub Actions default) that will abort the step.
-          RELEASE_FOUND=$(find compare/dists -type f -name Release | wc -l)
+          RELEASE_FOUND=$(find compare/dists -type f \( -name Release -o -name InRelease \) 2>/dev/null | wc -l)

And preserve the lftp exit code:

-              timeout 5m lftp -e "mirror --parallel=16; exit" https://${SERVER_URL}/dists/ || true
+              timeout 5m lftp -e "mirror --parallel=16; exit" https://${SERVER_URL}/dists/ || exit_status=$? || true

Finally guard the comparison:

-          elif [[ "${exit_status}" -eq 0 ]]; then
+          elif [[ -n "${exit_status}" && "${exit_status}" -eq 0 ]]; then

Apply the same fixes to every identical block below.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In .github/workflows/generate-redirector-config.yml around lines 190 to 196, the
variable exit_status is used without initialization because the lftp command's
exit code is discarded with || true, causing incorrect status classification.
Also, the find command can fail if the compare/dists directory does not exist,
which aborts the step due to set -e -o pipefail. To fix this, capture and
preserve the lftp exit code immediately after the command, avoid using || true,
and modify the find command to handle missing directories gracefully (e.g.,
check if the directory exists before running find or suppress errors). Apply
these changes consistently to all identical blocks in the file.

@igorpecovnik
Copy link
Member

I tested it and it seems resoults are not good.

810f27c

While doing this, a fallback is needed - main repo (rsync.armbian.com) should always be there as empty redirector config will also fail. Now (before this PR) its empty also if no mirror is synched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unuseable Mirrors - Redirector Behavior and Documentation
2 participants